﻿$(function () {
    $("#typeId").ligerComboBox({
        cancelable: false,
        width: 200,
        valueFieldID: 'hdnTypeId'
    });
});

function save() {
    var id = $("#hdnPositionId").val();
    var typeId = $("#hdnTypeId").val();
    var positionTitle = $("#txtPositionTitle").val();
    var positionCode = $("#txtPositionCode").val();
    var sort = $("#txtSort").val();

    if (IsEmpty(positionTitle)) {
        $.ligerDialog.error("职称名称不能为空");
        $("#txtPositionTitle").focus();
        return;
    }
    if (IsEmpty(positionCode)) {
        $.ligerDialog.error("职称编码不能为空");
        $("#txtPositionCode").focus();
        return;
    }
   
    $.ajax({
        url: "/Sysbase/Position/Save",
        type: "post",
        data: {
            Id: id,
            TypeId: typeId,
            PositionTitle: positionTitle,
            PositionCode: positionCode,
            Sort: sort
        },
        success: function (r) {
            var r = $.parseJSON(r);
            if (r.Result == 1) {
                parent.$("#btnSearch").click();
                closeDialog();
            }
            else if (r.Result == 0) {
                $.ligerDialog.error(r.Body);
            }
            else {
                $.ligerDialog.error("程序错误");
            }
        },
        error: function () {
            $.ligerDialog.error("程序错误");
        }
    });
}

function closeDialog() {
    frameElement.dialog.close();//关闭dialog
}